﻿<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<title></title>
		<script>
			onload = function(){
				var btn = document.getElementById("btn");
				btn.onclick = function(){
					jsonp();
				}
			}
			function handler(ddd){
				console.log(ddd);
			}
			function jsonp(city){
				var _script = document.createElement("script");
				_script.src = "http://10.9.154.109:8080/Web/weathereport?cityname="+city+"&callback=handler&time="+new Date().getTime()+Math.random();
				document.body.appendChild(_script);
			}	
			//[1,"sddf",{id:45, name:"YT", friends: [{name:"张三"},{name:"李四"},{name:"老王",friends:[{},{},{}]}]}]
		</script>
	</head>

	<body>
		这是第一个网页，测试JSONP
		<marquee direction="left">滚来滚去的证明页面没刷新</marquee>
		<button id="btn">这是一个跨域请求，请求天气预报的数据</button>
		<button id="btn" onclick="jsonp('BJ')">北京</button>
		<button id="btn" onclick="jsonp('SH')">上海</button>
		<button id="btn" onclick="jsonp('GZ')">广州</button>
	</body>

</html>



























